<template>
  <div>
    <div class="crud-group">
      <el-input
        v-model="paramsForm.clusterCode"
        placeholder="集群标识"
        clearable
      />
      <el-input
        v-model="paramsForm.agentHost"
        placeholder="agent地址"
        clearable
      />
      <div>
        <el-button
          type="success"
          icon="el-icon-search"
          @click="getData"
        >
          搜索
        </el-button>
        <el-button
          type="warning"
          icon="el-icon-refresh-left"
          @click="reset"
        >
          重制
        </el-button>
      </div>
    </div>

    <el-table
      v-loading="loading"
      border
      :data="data"
    >
      <el-table-column
        label="集群标识"
        prop="clusterCode"
      />
      <el-table-column
        label="Agent地址"
        prop="agentHost"
      />
      <el-table-column
        label="Agent端口"
        prop="agentPort"
      />
      <el-table-column
        label="最大线程数"
        prop="maxPoolSize"
      />
      <el-table-column
        label="最新心跳时间"
        prop="sendTime"
      />
    </el-table>

    <div class="pagination-container">
      <el-pagination
        layout="prev, pager, next,sizes,total"
        :page-sizes="[5, 10, 20, 30, 40]"
        :current-page="paramsForm.current"
        :page-size="paramsForm.size"
        :total="total"
        @size-change="()=>{
          paramsForm.size = val
          getData()
        }"
        @current-change="()=>{
          paramsForm.current = val
          getData(false)
        }"
      />
    </div>
  </div>

</template>

<script>
import coldAPi from '@/api/coldStandby/index'
const form = {
  current: 1,
  size: 10,
  clusterCode: '',
  agentHost: '',
  agentPort: '',
  maxPoolSize: '',
  agentType: '',
  agentKey: '',
  sendTime: ''
}
export default {
  components: {
  },
  data() {
    return {
      loading: false,
      editDialogVisible: false,
      selectedRow: null,
      total: 0,
      paramsForm: {...form},
      data: [

      ]
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData(resetPage = true) {
      if (resetPage) {
        this.paramsForm.current = 1
      }
      this.loading = true
      coldAPi.getAgentInfo(this.paramsForm).then(res => {
        this.data = res.records
        this.total = res.total
      }).finally(() => {
        this.loading = false
      })
    },
    reset() {
      this.paramsForm = {...form}
      this.getData()
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
